<template>
    <div class="config">
        <div class="config-header">配置信息列表</div>
        <div>
            <el-table
            :data="tableData"
            border
            style="width: 100%">
                <el-table-column
                    prop="id"
                    label="序号"
                    width="80">
                </el-table-column>
                <el-table-column
                    prop="name"
                    label="备注">
                </el-table-column>
                <el-table-column
                    prop="value"
                    label="取值"
                    width="180">
                </el-table-column>
                <el-table-column
                    prop="date"
                    label="创建时间"
                    width="180">
                </el-table-column>
                <el-table-column
                    label="操作"
                    width="180">
                    <template slot-scope="scope">
                        <el-button type="text" size="small" @click="changeValue(scope.row)">编辑</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="block">
                <el-pagination
                background
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage4"
                :page-sizes="[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]"
                :page-size="100"
                layout="total, sizes, prev, pager, next, jumper"
                :total="1000">
                </el-pagination>
            </div>
        </div>
    </div>
</template>
<script>
export default {
  name: 'configArg',
  data () {
    return {
      tableData: [{
        id: '1',
        value: '0.2',
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        id: '2',
        value: '0.2',
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1517 弄'
      }, {
        id: '3',
        value: '0.2',
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1519 弄'
      }, {
        id: '4',
        value: '0.2',
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }],
      currentPage4: 5
    }
  },
  methods: {
    changeValue (row) {
      console.log('row', row)
      this.$prompt('请输入修改数值', '编辑配置', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputType: 'number',
        inputErrorMessage: ''
      }).then(({ value }) => {
        console.log('tag', value)
        row.value = value
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '取消输入'
        })
      })
    },
    handleSizeChange (val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange (val) {
      console.log(`当前页: ${val}`)
    }
  }
}
</script>
<style lang="scss" scoped>
.config{
}
</style>
